package com.taobaolite.cart_has_items;

import com.taobaolite.item.Item;
import com.taobaolite.user.guest.Guest;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;
import java.io.Serializable;
import java.sql.Timestamp;

@Entity
@Table(name = "cart_has_items")
public class CartHasItems implements Serializable {

    @EmbeddedId
    @Column(nullable = false, updatable = false, unique = true)
    private CartPK cartId;
    @Column(nullable = false)
    private Integer amount;
    @Column(nullable = false, updatable = false)
    private Timestamp time;

    public CartHasItems(Item item, Guest guest, Integer amount, Timestamp time) {
        this.cartId = new CartPK(item, guest);
        this.amount = amount;
        this.time = time;
    }
    public CartPK getCartId() {
        return cartId;
    }

    public void setCartId(CartPK cartId) {
        this.cartId = cartId;
    }

    public Integer getAmount() {
        return amount;
    }

    public void setAmount(Integer amount) {
        this.amount = amount;
    }

    public Timestamp getTime() {
        return time;
    }

    public void setTime(Timestamp time) {
        this.time = time;
    }

    public CartHasItems() {}
}
